package backend;

public class Location
{
	
	private int id;
	private String country;
	private String airport;
	private String readerLocation;
	private Type readerType;
	
	public Location(int i, String c, String a, String l, Type t)
	{
		id = i;
		country = c;
		airport = a;
		readerLocation = l;
		readerType = t;
	}
	
	public int getId() {
		return id;
	}

	public String getCountry() {
		return country;
	}

	public String getAirport() {
		return airport;
	}

	public String getReaderLocation() {
		return readerLocation;
	}

	public Type getReaderType() {
		return readerType;
	}
	
	public boolean equals(Location other) {
		return id == other.getId();
	}
	
	public boolean isSameAirport(Location other) {
		return airport.equals(other.getAirport());
	}

	public static Type getType(String t)
	{
		if (t.toLowerCase() == "sorter")
			return Type.sorter;
		else if (t.toLowerCase() == "check-in")
			return Type.check_in;
		else if (t.toLowerCase() == "arrival")
			return Type.arrival;
		else if (t.toLowerCase() == "gateway")
			return Type.gateway;
		else if (t.toLowerCase() == "transfer")
			return Type.transfer;
		else if (t.toLowerCase() == "storage")
			return Type.storage;
		else
			return Type.unknown;
	}
	
	public static String getTypeName(Type t)
	{
		switch (t)
		{
		case sorter:
			return "Sorter";
		case check_in:
			return "Check-in";
		case arrival:
			return "Arrival";
		case gateway:
			return "Gateway";
		case transfer:
			return "Transfer";
		case storage:
			return "Storage";
		default:
			return "Unknown";
		}
	}
	
	public enum Type
	{
		sorter,
		check_in,
		arrival,
		gateway,
		transfer,
		storage,
		unknown
	}
	
}
